package com.bjkcst.baselib.utils;


import java.util.concurrent.Callable;

/**
 * name: glc
 * Date: 2022/5/13  15:32
 * Description:
 */
public abstract class CallableTemplate<V> implements Callable<V> {

    /**
     * 前置处理，子类可以Override该方法
     */
    public void beforeProcess() {
        System.out.println("before process....");
    }

    /**
     * 处理业务逻辑的方法,需要子类去Override
     *
     * @return
     */
    public abstract V process();

    /**
     * 后置处理，子类可以Override该方法
     */
    public void afterProcess(V result) {
        System.out.println("after process....");
    }

    @Override
    public V call() {
        beforeProcess();
        V result = process();
        afterProcess(result);
        return result;
    }
}


